<?php

namespace App\Http\Requests\Api;
use Illuminate\Validation\Rule;

class UserRegRequest extends BaseRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username'=>'required|unique:user,username|max:10|min:3',
            'password'=>'required|confirmed|max:16|min:3',
            'password_confirmation'=>'required|max:16|min:3',
            'nick_name'=>'required|min:1|max:10|unique:user,nick_name',
            'tel'=>'required|regex:/^1[3456789]\d{9}$/u|unique:user,tel',
            'email'=>'required|email|max:50|min:6|unique:user,email',
            'sex'=>[
                'required',
                Rule::in([0,1])
            ],
            'code'=>'required|numeric|regex:/\d{6}/',
            'verify_str'=>'required|min:10|max:100',
        ];
    }

    public function attributes()
    {
        return [
            'username'=>'用户名',
            'password'=>'密码',
            'password_confirmation'=>'确认密码',
            'nick_name'=>'昵称',
            'tel'=>'手机号',
            'email'=>'邮箱',
            'sex'=>'性别',
            'code'=>'验证码',
            'verify_str'=>'验证str',
        ];
    }

    public function messages()
    {
        return [
          'sex.in'=>'性别不在可选范围内'
        ];
    }
}
